<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection" />
    <meta content="emai=no" name="format-detection" />
    <link rel="stylesheet" type="text/css" href="<?php echo STATIC_HOST;?>shared/css/shared.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo STATIC_HOST;?>gene/css/common.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo STATIC_HOST;?>gene/css/orders.css" />
    <script type="text/javascript" src="<?php echo STATIC_HOST;?>shared/js/zepto-1.1.6.js"></script>
    <script type="text/javascript">
        function Cancel(order_id){
            var r=confirm("是否确认取消订单!");
            if(r){
                $.ajax({
                    url:"/sale/order/ajaxcancel",
                    type: "post",
                    cache: false,
                    dataType: 'json',
                    data:{order_id: order_id},
                    success:function(msg){
                        if(msg.error == 1)
                        {
                            zsmm.Toast.New("请重试！");
                        }else {
                            $("#order_id_"+order_id).remove();
                            $("#order_status_name_"+order_id).text("已取消");
                            zsmm.Toast.New(msg.msg);
                        }
                    },

                    error:function(){
                        zsmm.Toast.New("请重试！");
                    }
                });
            }
        }
    </script>
    <script>
        Zepto(function ($) {
            function onBridgeReady() {
                WeixinJSBridge.call('hideOptionMenu');
            }

            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                    document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                }
            } else {
                onBridgeReady();
            }
        });
    </script>
    <title>检测订单中心</title>
</head>

<body>
<div class="wrapper">
    <?php if(empty($orderlist)){ ?>
        <p style="margin: 40vh auto 0 auto;text-align: center;font-size:1.8rem;">您还没有订单，<a href="/product/detail?id=2">去逛逛</a></p>
    <?php }else{ ?>
    <?php foreach($orderlist as $k =>$v){ ?>
        <section class="order-list s<?php echo $v['order_status'] ?>">
            <div class="order-status" data-href="/sale/order/orderinfo?order_id=<?php echo $v['border_id'] ?>">
                <span class="s-right special" id="order_status_name_<?php echo $v['border_id'] ?>"><?php echo $v['order_status_name'] ?></span>
                <span>订单号：<?php echo $v['order_no'] ?></span>
            </div>
            <div class="order-info flex-wrapper flex-align-center" data-href="/sale/order/orderinfo?order_id=<?php echo $v['border_id'] ?>">
                <p>
						<span class="avatar">
								<?php echo $v['product_img'] ?>
							</span>
                </p>
                <div class="flex-1">
                    <p class="title clear"><span class="s-right">&yen; <?php echo $v['product_price'] ?></span><?php echo $v['product_name'] ?></p>
                    <p class="price">X <?php echo $v['product_num'] ?></p>
                </div>
            </div>
            <div class="order-total">
                共<?php echo $v['product_num'] ?>件商品，金额<span class="special">&yen; <?php echo $v['pay_amount'] ?></span>
            </div>
            <div class="order-action" id="order_id_<?php echo $v['border_id'] ?>" >
                <?php if($v['order_status'] == 1 ){ ?>
                    <a class="btn btn-cancel" href="javascript:void(0);" id="<?php echo $v['border_id'] ?>" onclick=Cancel(<?php echo $v['border_id'] ?>)>取消订单</a>
                    <a class="btn" href="/wxpay/?id=<?php echo $v['border_id'] ?>">付款</a>    
                <?php }elseif($v['order_status'] == 3 || $v['order_status'] == 4 ){ ?>
                   <?php if($v['category_id'] != 3){?>
                    <?php if($v['sample_status_0'] == 1 &&$v['sample_status_1'] == 1 ){ ?>
                        <a class="btn" href="/bind/sample/index?id=<?php echo $v['product_id']?>" >样本绑定</a>
                        <a class="btn" href="/sale/check/index?id=<?php echo $v['product_id']?>&order_id=<?php echo $v['border_id']?>">样本查看</a>
                    <?php }elseif($v['sample_status_0'] == 1 ){ ?>
                        <a class="btn" href="/bind/sample/index?id=<?php echo $v['product_id']?>" >样本绑定</a>
                    <?php }elseif($v['sample_status_1'] == 1 ){ ?>
                        <a class="btn" href="/sale/check/index?id=<?php echo $v['product_id']?>&order_id=<?php echo $v['border_id']?>">样本查看</a>
                    <?php } ?>
                  <?php } ?>
                <?php } ?>
            </div>
        </section>
    <?php } ?>
    <?php } ?>
</div>
<script type="text/javascript" src="<?php echo STATIC_HOST;?>shared/js/shared.js"></script>
<script type="text/javascript" src="<?php echo STATIC_HOST;?>gene/js/order.js"></script>
</body>

</html>